<template>
  <div>
    <a-card :bordered='false'>
      <f-search-form :more='true' @searchHandler='searchHandler' :tableObj='tableObj' :show-export-btn='true' :exportUrl='api.erpSearch.exportMxzList'>
        <f-search-form-item label='商品名称' name='drugNo' type='select' :data='api.erpSearch.selectDrugList' :params='queryParam' value-key='drugNo' label-key='drugsName' style='width: 350px' />
        <f-search-form-item  label='批号' name='lotNo' />
      </f-search-form>
      <f-table ref='table' rowKey='kcbm' settingKey='stockList' :showSetting='true' :tableColumns='columns' :scroll='{x:true}' :multiple='false' :operator='operator' :params='queryParam' :api='api.erpSearch.mxzList' handler='exportListHandler'>
        <span slot='kkps' slot-scope='text, record, index'>
           {{ Number(record.kcsl) - Number(record.zds) }}
        </span>
        <span slot='zjs' slot-scope='text, record, index'>
           <span v-if='record.jr'>{{ parseInt((Number(record.kcsl) - Number(record.zds)) / record.jr) }}</span>
        </span>
        <span slot='lhs' slot-scope='text, record, index'>
           <span v-if='record.jr'>{{ Number(record.kcsl) - parseInt((Number(record.kcsl) - Number(record.zds)) / record.jr) * record.jr }}</span>
        </span>
        <span slot='saleType' slot-scope='text, record'>
        <template>
        <span>
          <a-tag v-if="text=='CHA'" color='blue'>销售</a-tag>
          <a-tag v-if="text=='CHC'" color='blue'>退货</a-tag>
          <a-tag v-if='text==3' color='blue'>补货</a-tag>
          <a-tag v-if='text==4' color='blue'>票折</a-tag>
        </span>
        </template>
      </span>
        <span slot='ywfl' slot-scope='text, record, index'>
          <a-tag color='#FF0000' v-if='text=="ZS"'>
          招商
        </a-tag>
        <a-tag color='#00FF00' v-if='text=="ZY"'>
          自营
        </a-tag>
      </span>

      </f-table>
    </a-card>

  </div>
</template>
<script>
import api from "./../../js/api"

export default {
  name: "MingXiList",
  components: {},
  data() {
    let me = this
    //操作按钮
    let operator = []
    let customFlag = this.$store.state.user.customFlag
    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: {
        companyId: this.$store.state.user.companyId
      },
      tableObj: null,
      superAdmin: this.superAdmin,
      // 表头
      columns: [
        {
          title: "序号",
          width: "70px",
          align: "center",
          fixed: "left",
          customRender: (text, record, index) => index + 1
        },
        {
          title: "商品名称",
          align: "left",
          width: "100px",
          dataIndex: "spmc",
          ellipsis: true
        },
        {
          title: "规格",
          align: "left",
          width: "100px",
          ellipsis: true,
          dataIndex: "gg"
        },
        {
          title: "批号",
          align: "left",
          width: "70px",
          dataIndex: "ph"
        },
        {
          title: "仓库名称",
          align: "left",
          width: "130px",
          dataIndex: "ckmc"
        },
        {
          title: "剂型",
          align: "left",
          width: "100px",
          dataIndex: "jx"
        },
        {
          title: "生产企业",
          align: "left",
          width: "100px",
          dataIndex: "scqy"
        },
        {
          title: "上市许可持有人",
          align: "left",
          width: "100px",
          dataIndex: "cyr"
        },
        {
          title: "商品类别",
          align: "left",
          width: "70px",
          dataIndex: "splb"
        },
        {
          title: "件容",
          align: "left",
          width: "70px",
          dataIndex: "jr"
        },
        {
          title: "单位",
          align: "left",
          width: "70px",
          dataIndex: "dw"
        },
        {
          title: "可开票数",
          align: "left",
          width: "70px",
          dataIndex: "kkps",
          scopedSlots: { customRender: "kkps" }
        },
        {
          title: "有效期至",
          align: "left",
          width: "70px",
          dataIndex: "yxqz"
        },
        {
          title: "生产日期",
          align: "left",
          width: "100px",
          dataIndex: "scrq"
        },
        {
          title: "在单数",
          align: "left",
          width: "100px",
          dataIndex: "zds"
        },
        {
          title: "锁定数",
          align: "left",
          width: "100px",
          dataIndex: "sds"
        },
        {
          title: "库存数量",
          align: "left",
          width: "100px",
          dataIndex: "kcsl"
        },
        {
          title: "库存单价",
          align: "left",
          width: "100px",
          dataIndex: "kcdj"
        },
        {
          title: "计算价",
          align: "left",
          width: "100px",
          dataIndex: "jsj"
        },
        {
          title: "库存金额",
          align: "left",
          width: "100px",
          dataIndex: "kcje"
        },
        {
          title: "整件数",
          align: "left",
          width: "80px",
          dataIndex: "zjs",
          scopedSlots: { customRender: "zjs" }
        },
        {
          title: "零货数",
          align: "left",
          width: "80px",
          dataIndex: "lhs",
          scopedSlots: { customRender: "lhs" }
        },
        {
          title: "销售单价",
          align: "left",
          width: "100px",
          dataIndex: "kcdj"
        },
        {
          title: "入库数",
          align: "left",
          width: "100px",
          dataIndex: "rks"
        },
        {
          title: "入库额",
          align: "left",
          width: "100px",
          dataIndex: "rke"
        },
        {
          title: "出库数",
          align: "left",
          width: "100px",
          dataIndex: "cks"
        },
        {
          title: "出库额",
          align: "left",
          width: "100px",
          dataIndex: "cke"
        },
        {
          title: "结转数",
          align: "left",
          width: "100px",
          dataIndex: "jzs"
        },
        {
          title: "结转额",
          align: "left",
          width: "100px",
          dataIndex: "jze"
        },
        {
          title: "结转单价",
          align: "left",
          width: "100px",
          dataIndex: "jzdj"
        },
        {
          title: "最近含税进价",
          align: "left",
          width: "100px",
          dataIndex: "zjhsjj"
        },
        {
          title: "最近来货信息",
          align: "left",
          width: "100px",
          dataIndex: "zjlhxx"
        },
        {
          title: "供货商",
          align: "left",
          width: "100px",
          dataIndex: "ghs"
        },
        {
          title: "可否销售",
          align: "left",
          width: "100px",
          dataIndex: "kfxs"
        },
        {
          title: "业务分类",
          align: "left",
          width: "100px",
          dataIndex: "ywfl",
          scopedSlots: { customRender: "ywfl" }
        }
      ],
      operator: operator
    }
  },
  created() {
  },
  mounted() {
    this.tableObj = this.$refs.table
  },
  methods: {
    onCopy() {
      this.$message.success("复制成功!")
    },
    initSettle(record) {
      // this.http.confirm(this, {
      //   content: '确认初始化结算吗?',
      //   url: api.payment.initSettlePayment,
      //   data: {
      //     orderDetailsId: record.orderDetailsId
      //   }
      // })
    },
    clearExport() {
      this.http.post(this, {
        url: this.api.bod.clearExportData
      })
    }
  }
}
</script>
